<!doctype html>
<html>

<head>
	<meta charset="UTF-8">
	<title>注册</title>
	<meta name="viewport"
		content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link rel="stylesheet" href="css/mui.min.css" />
	<!-- build:css css/app.css -->
	<link rel="stylesheet" href="css/base.css" />
	<link rel="stylesheet" href="css/common.css">
	<!-- endbuild -->
	<style>
		.register .flex-row-center label {
			font-size: 14px;
		}

		body,
		.mui-content {
			background: #ffffff;
		}
	</style>
</head>

<body>
	<header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		<h1 class="mui-title">注册</h1>
	</header>
	<div class="mui-content">
		<div class="register">
			<ul class="mui-table-view">
				<li class="mui-table-view-cell">
					<div class="flex-row-center">
						<label>手机号</label>
						<input class="phone" type="text" placeholder="请输入" />
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div class="flex-row-center">
						<label>验证码</label>
						<input class="code" type="text" placeholder="请输入" maxlength="6" />
						<span id="getCode" class="get-code">获取验证码</span>
						<span id="codeDate" class="get-code mui-hidden">180s</span>
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div class="flex-row-center">
						<label>密码</label>
						<input class="password" type="password" placeholder="请输入" />
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div class="flex-row-center">
						<label>确认密码</a>
							<input class="confirm" type="password" placeholder="请输入" />
					</div>
				</li>
			</ul>
		</div>
		<button type="button" data-loading-text="提交中" id="register"
			class="button button-red mui-btn mui-btn-block">注册</button>
	</div>
</body>
<script src="js/mui.min.js"></script>
<script src="js/zepto.min.js"></script>
<!-- build:js js/app.js -->
<script src="js/api.js"></script>
<script src="js/tools.js"></script>
<!-- endbuild -->
<script>
	mui.ready(function () {
		var phone = $('.phone');
		var code = $('.code');
		var password = $('.password');
		var confirm = $('.confirm');

		// 获取验证码
		$('#getCode').on('tap', function () {
			window.getCode(phone.val(), 0)
		})
		// 点击注册
		$('#register').on('tap', function () {
			if (isPhone(phone.val()) == false || isPassword(password.val(), confirm.val()) == false) {
				return false
			}
			if (code.val() == '') {
				mui.alert('请输入验证码！');
				return false
			}
			mui.ajax(config.ME_API + 'h5/h5UserRegis', {
				data: {
					phone: phone.val(),
					password: password.val(),
					msg: code.val()
				},
				dataType: 'json',
				type: 'post',
				timeout: 10000,
				success: function (res) {
					if (res.code == 2) {
						mui.toast('注册成功!');
						setTimeout(function () {
							mui.openWindow('login.html')
						}, 500)
					} else {
						mui.toast(res.msg)
					}
				}
			});
		})
	})
</script>

</html>